import {EventBus} from "@/event";
import {tableMetas} from "@/metas/DbTableMetas";
import {demoMenus} from "@/components/OptionsMetaData";

export const BasicContainerChangeEvent = {
    NameChange: 'NameChange',
    EditType: 'EditTypeChange'
}
const EditTypeData = [
    {label: '模态框', value: 'modal'},
    {label: '抽屉框', value: 'drawer'},
]
const commonContainerMetas = [
    {field: 'editType', title: '编辑框', type: 'radio', default: 'modal', data: EditTypeData, change(val, meta, model) {
            EventBus.publish(BasicContainerChangeEvent.EditType, val)
        }, rules: [{required: true}]
    },
    {field: 'name', title: '功能名', type: 'text', placeholder: '用户管理'
        , rules: [{required: true, message: '功能名必填'}], change(value, meta, model) {
            model.comment = value;
            EventBus.publish(BasicContainerChangeEvent.NameChange, value)
        }, default: 'xx管理'},
]

const containerFunction = [
    {field: 'desc', type: 'divider', title: '模块配置'},
    ...commonContainerMetas,
    {field: 'menuId', title: '父菜单', type: 'treeSelect', data: demoMenus},
]

const TableContainerTabMetas = {
    basic: {label: '基础配置', metas: [...tableMetas, ...containerFunction]},
}

const BasicContainerTabMetas = {
    basic: {label: '基础配置', metas: [...commonContainerMetas, ...tableMetas]}
}
export {TableContainerTabMetas, BasicContainerTabMetas}
